package com.leoman.spinningmachine.tab1;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.leoman.helper.util.DrawableUtil;
import com.leoman.helper.util.ViewHolder;
import com.leoman.spinningmachine.R;

/**
 * Created by Administrator on 2018/4/24.
 * 全部功能适配器
 */

public class FunctionAdapter extends BaseAdapter {

    Context mContext;
    private int[] icons;
    private String[] names;

    public FunctionAdapter(Context mContext, int[] icons, String[] names) {
        this.mContext = mContext;
        this.icons = icons;
        this.names = names;
    }

    @Override
    public int getCount() {
        return icons.length;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        if (view == null)
            view = LayoutInflater.from(mContext).inflate(R.layout.item_function, null);
        TextView tv_name = ViewHolder.get(view, R.id.tv_name);

        tv_name.setText(names[position]);
        DrawableUtil.setDrawabTop(tv_name, ContextCompat.getDrawable(mContext, icons[position]));
        return view;
    }
}
